package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;



import static com.sky.enumeration.OperationType.INSERT;
import static com.sky.enumeration.OperationType.UPDATE;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     *回显员工数据，密码比对
     * @param empId
     * @return
     */
    @Select("select * from employee where id = #{empId}")
    Employee getEmployeeById(Long empId);

    /**
     * 修改密码
     * @param newPassword
     * @param empId
     */
    @Update("update employee set password = #{newPassword} where id = #{empId} ")
    void updatePassword(String newPassword,Object empId);

    /**
     * 新增员工
     * @param employee
     */
    @AutoFill(INSERT)
    void addEmployee(Employee employee);

    /**
     * 分页查询
     * @param name
     * @return
     */
    Page<Employee> page(String name);

    /**
     * 更新员工信息
     * @param employee
     */
    @AutoFill(UPDATE)
    void updateEmp(Employee employee);

    /**
     * 修改员工账号状态
     * @param employee
     */
    @AutoFill(UPDATE)
    void controlEmpStatus(Employee employee);
}
